/* eslint-disable no-new */
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router/router'
import hljs from 'highlight.js'
// 安装Bootstrap
// npm install bootstrap --save-dev
// npm install --save jquery popper.js

Vue.config.productionTip = false;
// 在main.js定义自定义指令
Vue.directive('highlight', function (el) {
  // let blocks = el.querySelectorAll('pre code');
  // 设置使用换行
  hljs.configure({useBR: true});
  // 必须与markdown.css配置使用，否则无效果
  $('img').each(function () {
    $(this).addClass('custom-img')
  });
  $('pre').each(function () {
    $(this).addClass('custom-pre')
  });
  $('table').each(function () {
    $(this).addClass('custom-table')
  });
  $('thead > tr > th').each(function () {
    $(this).addClass('custom-th')
  });
  $('tbody > tr > td').each(function () {
    $(this).addClass('custom-td')
  })
  // $('pre code').each(function () {
    // let lines = $(this).text().split('\n').length;
    // console.log(lines)
    // var $numbering = $('<ul/>').addClass('pre-numbering');
    // $(this)
    //   .addClass('has-numbering')
    //   .parent()
    //   .append($numbering);
    // var nbsplen = lines < 10 ? "15px" : (lines < 100 ? "20px" : (lines < 1000 ? "25px" : "30px"));
    // $numbering.parent().find("code").css({marginLeft: nbsplen});
    // $numbering.css({width: nbsplen});
    // let i = 1;
    // for (; i <= lines; i++) {
    //   var nbsp = lines < 10 ? ""
    //     : (lines < 100 ? (i < 10 ? " " : "") : (lines < 1000 ? (i < 10 ? "  " : (i < 100 ? " " : "")) : ""));
    //   $numbering.append($('<li/>').text(nbsp + i));
    // }
  // });
});

new Vue({
  el: '#app',
  router,
  components: {App},
  template: '<App/>'
});
